/*
 * badl_led.h
 *
 *  Created on: 24/02/2010
 *      Author: Gustavo
 */

#ifndef BADL_LED_H_
#define BADL_LED_H_


// ************************* INCLUDES **************************

#include "target.h"
#include "phal_io_port.h"

// *********************** DEFINITIONS *************************

typedef struct {
	phal_io_port_PortId port;
	phal_io_port_PinId pin;
	BOOL invertedLogic;
} badl_led_LedType;

#define badl_led_GET_ACTUAL_STATUS_VALUE(led, status) \
	((badl_led_leds[led].invertedLogic)\
		? (!status)\
		: (status)\
	)

// ******************** GLOBAL VARIABLES ***********************

extern CODE_MEMORY badl_led_LedType badl_led_leds[];

// *************************** BODY ****************************

extern void badl_led_init(void);

#define badl_led_getNumberOfLeds() \
	(sizeof(badl_led_leds)/sizeof(badl_led_leds[0]))

#define badl_led_turnOn(led) \
	phal_io_port_setPinStatus(badl_led_leds[led].port, badl_led_leds[led].pin, badl_led_GET_ACTUAL_STATUS_VALUE(led, phal_io_port_STATUS_ON));

#define badl_led_turnOff(led) \
	phal_io_port_setPinStatus(badl_led_leds[led].port, badl_led_leds[led].pin, badl_led_GET_ACTUAL_STATUS_VALUE(led, phal_io_port_STATUS_OFF));


#endif /* BADL_LED_H_ */
